- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3
Add package-json subcommand #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            jasonkarns
  wants to merge
  16
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
bin
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
                
     Open
            
            
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    `nodenv-package` is the corrolary to nodenv-shell, nodenv-local, and nodenv-global. Right now, it is just a subcommand to show the version selected from package.json. In the future, it should also be used to _set_ the version in package.json.
Separately; old code had a bug where the first conditional branch would never be executed (the `get_version_respecting_precedence` function never returned non-zero). This is actually a good thing, because we wouldn't _want_ to print anything to STDERR in this hook, anyway. Also, this hook script is sourced by nodenv so it shouldn't have a shebang, nor be executable. Lastly, we rely on nodenv ensuring each plugin's `bin/` dir is added to PATH so we can just invoke `nodenv-package` directly.
Both the 3rd party deps are symlinked to bin, but we don't actually want to lint them. Meanwhile, the only files that exist in bin that _should_ be linted, are symlinks to libexec. So we can just lint them there.
npm won't include any symlinks in the tarball, so we need to explicitly include the main bin. Pointing to libexec allows npm to make the symlink from node_modules/.bin/ -> libexec/ The other bins aren't necessary because they are provided by npm automaticaly (and included in path that's to npm). (Assuming this is installed globally, which would ensure the bins are in PATH.)
These vars are set by nodenv itself, so they'll likely only be set if the tests were run via nodenv (as is the case with `npm t`). Though other maintainers may have some of these set in the shell profile, so we need to unset them regardless.
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Significant refactor to support the traditional subcommand/bin/libexec
structure of nodenv plugins.
plugin_rootfrom bin, so we aren't polluting user's PATH with more stuff.nodenv package-jsonsubcommand. This subcommand presently is a "reader" for package.json just asnodenv localprints the version specified from local.node-versionfile. Intend to have this command also be a "writer" in the future.nodenv-version-fileandnodenv-version-file-read. The benefit is that the origin hook can now print the path to the actual package.json that is affecting the node version, along with the version_spec from said file. It invokes these utilities without needing to source anything.Also addresses some latent bugs:
PWDbut should have been usingNODENV_DIRnodenv-package-json-engine/libexec/nodenv-package-json-engine
Line 72 in dbfd936
https://github.com/nodenv/nodenv/blob/4e096a821ad1e3c55634586c4798da472be5520c/libexec/nodenv-version-file#L25-L27
todo: